/** @file               sw_msgq.h
 *  @copyright          Copyright (C) 2006-2026 flyfish (tenggui_fu@126.com)
 *  @brief              This file is part of the swallow library
 *  @author             $Author: flyfish $
 *  @version            $Rev: 385 $
 *  @date               $Date: 2016-12-22 00:12:05 +0800 (周四, 22 12月 2016) $
 */
#ifndef __SW_MSGQ_H__
#define __SW_MSGQ_H__

#ifdef __cplusplus
extern "C" {
#endif

typedef SW_VOID *SW_MSGQ;
typedef SW_VOID *SW_MSG;

#define SW_INVALID_MSGQ NULL
#define SW_INVALID_MSG  NULL

SW_API SW_RET SW_InitMsgqAPI(SW_VOID);
SW_API SW_RET SW_RunMsgqAPI(SW_VOID);
SW_API SW_RET SW_StopMsgqAPI(SW_VOID);
SW_API SW_RET SW_ExitMsgqAPI(SW_VOID);
SW_API SW_MSGQ SW_CreateMsgq(SW_UINT32 msgMax);
SW_API SW_RET SW_DeleteMsgq(SW_MSGQ msgq);
SW_API SW_MSG SW_CreateMsg(SW_UINT32 cmd, SW_UINT32 flag, SW_UINT32 ack, const SW_VOID *pData, SW_UINT32 dataLen);
SW_API SW_RET SW_DeleteMsg(SW_MSG msg);
SW_API SW_RET SW_SetMsgMsgqDst(SW_MSG msg, SW_MSGQ msgq);
SW_API SW_MSGQ SW_GetMsgMsgqDst(SW_MSG msg);
SW_API SW_RET SW_SetMsgMsgqSrc(SW_MSG msg, SW_MSGQ msgq);
SW_API SW_MSGQ SW_GetMsgMsgqSrc(SW_MSG msg);
SW_API SW_RET SW_SetMsgCmd(SW_MSG msg, SW_UINT32 cmd);
SW_API SW_UINT32 SW_GetMsgCmd(SW_MSG msg);
SW_API SW_RET SW_SetMsgFlag(SW_MSG msg, SW_UINT32 flag);
SW_API SW_UINT32 SW_GetMsgFlag(SW_MSG msg);
SW_API SW_RET SW_SetMsgAck(SW_MSG msg, SW_UINT32 ack);
SW_API SW_UINT32 SW_GetMsgAck(SW_MSG msg);
SW_API SW_RET SW_SetMsgData(SW_MSG msg, const SW_VOID *pData, SW_UINT32 dataLen);
SW_API SW_RET SW_GetMsgData(SW_MSG msg, SW_VOID *pData, SW_UINT32 *pDataLen);
SW_API SW_UINT32 SW_GetMsgDataLen(SW_MSG msg);
SW_API SW_RET SW_SendMsg(SW_MSGQ msgqDst, SW_MSGQ msgqSrc, SW_MSG msg);
SW_API SW_RET SW_TrySendMsg(SW_MSGQ msgqDst, SW_MSGQ msgqSrc, SW_MSG msg);
SW_API SW_RET SW_TimeSendMsg(SW_MSGQ msgqDst, SW_MSGQ msgqSrc, SW_MSG msg, SW_UINT32 msec);
SW_API SW_RET SW_RecvMsg(SW_MSGQ msgq, SW_MSG *pMsg);
SW_API SW_RET SW_TryRecvMsg(SW_MSGQ msgq, SW_MSG *pMsg);
SW_API SW_RET SW_TimeRecvMsg(SW_MSGQ msgq, SW_MSG *pMsg, SW_UINT32 msec);
SW_API SW_RET SW_SendMsgAck(SW_MSG msg, SW_UINT32 ack);
SW_API SW_RET SW_TrySendMsgAck(SW_MSG msg, SW_UINT32 ack);
SW_API SW_RET SW_TimeSendMsgAck(SW_MSG msg, SW_UINT32 ack, SW_UINT32 msec);
SW_API SW_RET SW_ClearMsgq(SW_MSGQ msgq);

#ifdef __cplusplus
}
#endif

#endif

